'*******************************************************************************
' *  
' *  Product: GSALib
' *  Description: A C# API for accessing the Google Search Appliance.
' *
' *  (c) Copyright 2008 Michael Cizmar + Associates Ltd.  (MC+A)
' *  
'*******************************************************************************


Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Text
Imports Gsalibvb.GSALib.Utils

Namespace GSALib.GSA
    ''' <summary>
    ''' Class for creating object that contains resuls of Request
    ''' <para>Author Albert Ghukasyan</para>
    ''' </summary>
    Public NotInheritable Class Result
#Region "Variables"

        Private mimeType As String
        Private indentation As Integer
        Private url As String
        Private escapedUrl As String
        Private title As String
        Private rating As Integer
        Private metas As Hashtable
        Private fields As Hashtable
        Private summary As String
        Private language As String
        Private cacheDocId As String
        Private cacheDocEncoding As String
        Private cacheDocSize As String
        Private crawelDate As String

#End Region

#Region "Constructor"

        Friend Sub New()
            metas = New Hashtable()
            fields = New Hashtable()
        End Sub

#End Region

#Region "Get/Set Properties"

        Public Sub setIndentation(ByVal indentation As Integer)
            Me.indentation = indentation
        End Sub

        Public Sub setLanguage(ByVal language As String)
            Me.language = language
        End Sub

        Public Sub setCrawelDate(ByVal crawelDate As String)
            Me.crawelDate = crawelDate
        End Sub

        Public Sub setMetas(ByVal metas As Hashtable)
            Me.metas = metas
        End Sub

        Public Sub addMeta(ByVal key As String, ByVal value As String)
            Me.metas.Add(key, value)
        End Sub

        Public Sub setFields(ByVal fields As Hashtable)
            Me.fields = fields
        End Sub

        Public Sub addField(ByVal key As String, ByVal value As String)
            Me.fields.Add(key, value)
        End Sub

        Public Sub setMimeType(ByVal mimeType As String)
            Me.mimeType = mimeType
        End Sub

        Public Sub setRating(ByVal rating As Integer)
            Me.rating = rating
        End Sub

        Public Sub setSummary(ByVal summary As String)
            Me.summary = summary
        End Sub

        Public Sub setTitle(ByVal title As String)
            Me.title = title
        End Sub

        Public Sub setUrl(ByVal url As String)
            Me.url = url
        End Sub

        Public Function getIndentation() As Integer
            Return indentation
        End Function

        Public Function getLanguage() As String
            Return language
        End Function

        Public Function getCrawelDate() As String
            Return crawelDate
        End Function

        Public Function getMetas() As Hashtable
            Return metas
        End Function

        Public Function getMeta(ByVal name As String) As String
            Return Util.getString(metas(name), Nothing, False)
        End Function

        Public Function getFields() As Hashtable
            Return fields
        End Function

        Public Function getField(ByVal name As String) As String
            Return Util.getString(fields(name), Nothing, False)
        End Function

        Public Function getMimeType() As String
            Return mimeType
        End Function

        Public Function getRating() As Integer
            Return rating
        End Function

        Public Function getSummary() As String
            Return summary
        End Function

        Public Function getTitle() As String
            Return title
        End Function

        Public Function getUrl() As String
            Return url
        End Function

        Public Function getCacheDocEncoding() As String
            Return cacheDocEncoding
        End Function

        Public Sub setCacheDocEncoding(ByVal cacheDocEncoding As String)
            Me.cacheDocEncoding = cacheDocEncoding
        End Sub

        Public Function getCacheDocId() As String
            Return cacheDocId
        End Function

        Public Sub setCacheDocId(ByVal cacheDocId As String)
            Me.cacheDocId = cacheDocId
        End Sub

        Public Function getCacheDocSize() As String
            Return cacheDocSize
        End Function

        Public Sub setCacheDocSize(ByVal cacheDocSize As String)
            Me.cacheDocSize = cacheDocSize
        End Sub

        Public Function getEscapedUrl() As String
            Return escapedUrl
        End Function

        Public Sub setEscapedUrl(ByVal escapedUrl As String)
            Me.escapedUrl = escapedUrl
        End Sub

#End Region

#Region "ToString"

        Public Overloads Overrides Function ToString() As String
            Dim buffer As New StringBuilder()

            buffer.Append("GSAResult[")
            buffer.Append("mimeType = ").Append(mimeType)
            buffer.Append(", indentation = ").Append(indentation)
            buffer.Append(", url = ").Append(url)
            buffer.Append(", escapedUrl = ").Append(escapedUrl)
            buffer.Append(", title = ").Append(title)
            buffer.Append(", rating = ").Append(rating)
            buffer.Append(", metas = ").Append(metas)
            buffer.Append(", fields = ").Append(fields)
            buffer.Append(", summary = ").Append(summary)
            buffer.Append(", language = ").Append(language)
            buffer.Append(", cacheDocId = ").Append(cacheDocId)
            buffer.Append(", cacheDocEncoding = ").Append(cacheDocEncoding)
            buffer.Append(", cacheDocSize = ").Append(cacheDocSize)
            buffer.Append("]")

            Return buffer.ToString()
        End Function

#End Region
    End Class
End Namespace
